define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
			//修改顶部按钮弹窗大小
			$(".btn-add").data("area",["70%","90%"])
			// $(".btn-edit").data("area",["70%","90%"])
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'holiday/index' + location.search,
                    add_url: 'holiday/add',
                    edit_url: 'holiday/edit',
                    del_url: 'holiday/delete',
                    multi_url: 'holiday/multi',
                    table: 'holiday',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        // {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'startday', title: __('开始日期'),operate:false},
                        {field: 'endday', title: __('结束日期'),operate:false},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ],
				//禁用默认搜索
				search: false,
				//启用普通表单搜索
				commonSearch: true,
				//可以控制是否默认显示搜索单表,false则隐藏,默认为false
				searchFormVisible: true,
				showSearch: false,
            });
			table.on('post-body.bs.table',function () {
			    $('.btn-editone').data("area",["70%","90%"]);
			}),
            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});